package com.scpii.universal.pns.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.scpii.universal.pns.dao.FieldDao;
import com.scpii.universal.pns.entity.Field;
import com.scpii.universal.pns.entity.Users;

@Service
public class FieldServiceImpl extends PnsBaseServiceImpl<Field, Long> implements
		FieldService {
	@Resource
	private FieldDao fieldDao;

	@Resource
	public void setBaseDao(FieldDao fieldDao) {
		super.setBaseDao(fieldDao);
	}

	@Override
	public List<Field> getUserFieldsByAppId(int appid) {
		StringBuffer hql = new StringBuffer("from Field a where ");
		hql.append("a.appId=:appId and a.categoriesId=:categoriesId");
		Map<String, Object> argsMap = new HashMap<String, Object>();
		long uniAppId = 111000000000l + appid;
		argsMap.put("appId", uniAppId);
		argsMap.put("categoriesId", Users.TARGET_ID);
		return fieldDao.hqlGetList(hql.toString(), argsMap);
	}

}
